var pp = null,
timer = null,
locationURL = window.location.href,
islogin = 0,
hadpingfen = 0;
var IKF = {
//评分评论接口地址
starUrl: function(id){
	return Root + 'index.php?s=user-comm-get-id-'+ id +'-sid-'+ (Sid || '1');
},
//判断用户是否登录
checkcookie: function(){
	if(document.cookie.indexOf('auth=') >= 0){
		islogin = 1;
		return true;
	}
	return false;
},
//清除 Cookie
clearcookie: function() {
	var keys=document.cookie.match(/[^ =;]+(?=\=)/g);
    if (keys) {
        for (var i = keys.length; i--;)
        document.cookie=keys[i]+'=0;expires=' + new Date(0).toUTCString()
    }
},
//判断来源
// utm_source: function(){
// 	var ref = '';
// 	if (document.referrer.length > 0) {
// 		ref = document.referrer;
// 	}try {
// 		if (ref.length == 0 && opener.location.href.length > 0) {
// 			ref = opener.location.href;
// 		}
// 	} catch (e) {}
// 	console.log(ref);
// 	return ref;
// },
//判断是否显示其他资源/*IKF.utm_source().indexOf('tieba.baidu.com') != -1 || IKF.utm_source().indexOf('neets.cc') != -1 || */
// isOther: function(){
// 	// if(IKF.checkcookie() || noLogin === 'play'){
// 	// 	$('.d-other').css('visibility','visible')
// 	// }
// 	$('.d-other').css('visibility','visible')
// },
//排行榜
rankTop: function(obj){
	obj.eq(0).find('.normal').hide();
	obj.eq(0).find('.d-media').show();
	obj.eq(0).addClass('active');
	obj.hover(function() {
		$('.d-media').hide();
		$('.normal').show();
		obj.removeClass('active');
		obj.eq(0).find('.normal').show();
		$(this).find('.normal').hide();
		$(this).find('.d-media').show();
		$(this).addClass('active');
	}, function() {
	});
},
//显示隐藏
hs: function(id,div,cur) {
	id.hover(function () {
		$(this).addClass(cur);
		div.show();
	}, function () {
		$(this).removeClass(cur);
		div.hide();
	});
},
//富媒体广告
// FMT: function(){
// 	//document.write ('');
// },
//左右侧滚动 HomeScroll(".Mid4_L,.Mid_L",".Mid4_R,.Mid_R");//左右侧滚动
HomeScroll: function(a,c,num,num2){
	if($(a).length>0&&$(c).length>0){var f=$(a),b=$(c),d=f.offset().top,e=b.offset().top;function g(){var k=$(window).scrollLeft(),r=$(window).scrollTop(),i=$(document).height(),o=$(window).height(),l=f.height(),j=b.height(),m=l>j?e:d,n=l>j?b:f,p=l>j?num+f.offset().left+f.outerWidth(true)-k:num2+b.offset().left-f.outerWidth(true)-k,h=l>j?j:l,q=l>j?l:j,s=parseInt(q-o)-parseInt(h-o);$(a+","+c).removeAttr("style");if(i<o||h>q||r<m||r<=(h-o+m)){n.removeAttr("style")}else{if(o>h&&(r-m)>=s||o<h&&(r-m)>=(q-o)){n.attr("style","margin-top:"+s+"px;")}else{n.attr("style","_margin-top:"+(r-m)+"px;position:fixed;left:"+p+"px;"+(o>h?"top":"bottom")+":0;")}}}$(window).resize(g).scroll(g).trigger("resize")}
},
// 移除广告
// removeAd: function(){
// 	$('#cs_left_couplet,#cs_right_couplet,#cs_rich_close_left,#cs_rich_close_right').remove();
// },
//图超出指定高度，鼠标放上去自动滚动超出部分
imgHeight: function(){
	var scrollObj = null;
	//样式
	var cssCode='<style type="text/css">';
	cssCode+='.topDiv,.bottomDiv{height:50%;width:100%;cursor:pointer;position:absolute;}';
	cssCode+='.bottomDiv{margin-top:67.5px;}';
	cssCode+='.imgDiv{position:absolute;}';
	cssCode+='</style>';
	$("head").append($(cssCode));
	//布局
	var $topDiv=$('<div class="topDiv"></div>');
	var $bottomDiv = $('<div class="bottomDiv"></div>');
	var $scrollDiv = $('.d-vodnews-picbox');
	$scrollDiv.find('.d-vodnews-pic').append($topDiv);
	$scrollDiv.find('.d-vodnews-pic').append($bottomDiv);
	$scrollDiv.find('img').addClass('imgDiv');

	$scrollDiv.find('.bottomDiv').mousemove(function () {
		clearInterval(scrollObj);
		var that = $(this).parent().parent();
		scrollObj = setInterval(function () {
			var currentTop = parseInt(that.find('.d-vodnews-pic img').css('top')) || 0;
			var mainH = that.find('.d-vodnews-pic img').height();
			if (currentTop + mainH > that.height()) {
				currentTop--;
				that.find('.d-vodnews-pic img').css('top', currentTop);
			}
		}, 8);
		//$(this).css('margin-top', that.height() / 2);
	}).mouseleave(function () {
		clearInterval(scrollObj);
	});

	$scrollDiv.find('.topDiv').mouseover(function () {
		clearInterval(scrollObj);
		var that = $(this).parent().parent();
		scrollObj = setInterval(function () {
			var currentTop = parseInt(that.find('.d-vodnews-pic img').css('top')) || 0;
			if (currentTop < 0) {
				currentTop++;
				that.find('.d-vodnews-pic img').css('top', currentTop);
			}
		}, 8);
	}).mouseleave(function () {
		clearInterval(scrollObj);
	});
},
//收藏和订阅
clickRss: function(){
	// interest-sect
	$(".user-bt").each(function(){
		var $btn = $(this).find(".sect-btn");
		var $cancel = $(this).find(".cancel");
		var $div =$(this).find(".sect-show");

		$btn.on('click',function(){
			if(!IKF.checkcookie()) {
				IKF.login_form();
				return false;
			}
			$.showfloatdiv({txt:'数据提交中...',cssname:'loading'});
			var curobj=$(this);
			var $url = $btn.attr('data');
			$.get($url.indexOf('index.php') <= 0 ? '/index.php' + $url.split('/')[1] : $url,
				function(r){
					console.log(r);
					$.hidediv(r);
					if(parseInt(r.rcode)>0){
						curobj.hide();
						$div.show();
						$cancel.show();
					}else{
						if(parseInt(r['yjdy'])>0){
							if(parseInt(r['yjdy'])==1){
								curobj.hide(r);
								$div.show();
								$cancel.show();
							}
						}
					}
			},'json');
		});
		$cancel.on('click',function(){
			$.showfloatdiv({txt:'数据提交中...',cssname:'loading'});
			var $url = $cancel.attr('data');
			$.get($url.indexOf('index.php') <= 0 ? '/index.php' + $url.split('/')[1] : $url,function(r){
				$.hidediv(r);
				if(parseInt(r.rcode)>0){
					$btn.show();
					$div.hide();
				}
			},'json');
		});
	});
},
//是否关注公共方法
isRssFavPublic: function(r){
	if (r['loveid'] != null) {
		$(".interest-sect .sect-btn").hide();
		$(".interest-sect .sect-show").show();
		$(".loveidbox .sect-btn").hide();
		$(".loveidbox .sect-show").show();
	} else {
		$(".interest-sect .sect-btn").show();
		$(".interest-sect .sect-show").hide();
		$(".loveidbox .sect-btn").show();
		$(".loveidbox .cancel").hide();
	}
	if (r['remindid'] != null) {
		$(".interest-rss .rss-btn").hide();
		$(".interest-rss .rss-show").show();
		$(".remind .rss-btn").hide();
		$(".remind .rss-show").show();
	} else {
		$(".interest-rss .rss-btn").show();
		$(".interest-rss .rss-show").hide();
		$(".remind .rss-btn").show();
		$(".remind .del").hide();
	}
},
//是否关注和收藏
isRssFav: function(r){
	if(r){
		IKF.isRssFavPublic(r);
	}else{
		if($("#_void_id").val()){
			$.ajax({
				url : IKF.starUrl($("#_void_id").val()),
				success : function(data) {
					if (data.star != undefined && data.star != null) {
						IKF.isRssFavPublic(data.star);
					};
				}
			});
		}
	}
},
//设置站内站外
// setOut: function(){
// 	if(parseInt(localStorage.playStyle) === 2 || localStorage.playStyle === undefined){
// 		localStorage.playStyle = 1;
// 		if(setting){
// 			playStyle = parseInt(localStorage.playStyle);
// 			Play(pv,playname);
// 		}
// 	}
// },
//注册
userreg: function() {
	if ("" == $("#email").val()) $.showfloatdiv({
		txt: "请输入正确的Emial"
	}), $("#email").focus(), $.hidediv({});
	else {
		if ("" != $("#pwd").val()) return $("#regform").qiresub({
			curobj: $("#register"),
			txt: "数据提交中,请稍后...",
			onsucc: function(a) {
				if ($.hidediv(a), parseInt(a["rcode"]) > 0) {
					qr.gu({
						ubox: "unm",
						rbox: "innermsg",
						h3: "h3",
						logo: "userlogo"
					});
					try {
						PlayHistoryObj.viewPlayHistory("playhistory")
					} catch (b) {}
					$("#cboxClose").trigger("click")
					//登录后隐藏漂浮广告
					// IKF.removeAd();
					//判断是否显示其他资源
					// IKF.isOther();
					//是否收藏和订阅
					IKF.isRssFav();
					//判断站内外播放
					// IKF.setOut();
					//判断是否为站内外播放
					// IKF.usedSetPlay();
					//登录切换到CK播放器
					if(window.location.href.indexOf('/ac/') != -1 && window.location.href.indexOf('.html') != -1){
						if(playConfig.setting){
							Play(playConfig.pv,playConfig.playname);
						}
					}
				} else - 3 == parseInt(a["rcode"])
			}
		}).post({
			url: Root + "index.php?s=user-reg-index"
		}), !1;
		$.showfloatdiv({
			txt: "请输入密码"
		}), $("#pwd").focus(), $.hidediv({})
	}
},
//登录
userlogin: function() {
	this.clearcookie()
	if ($("#username").val() == '') {
		$.showfloatdiv({
			txt: '请输入正确的用户名'
		});
		$("#username").focus();
		$.hidediv({});
	} else if ($("#password").val() == '') {
		$.showfloatdiv({
			txt: '请输入密码'
		});
		$("#password").focus();
		$.hidediv({});
	} else {
		$("#loginform").qiresub({
			curobj: $("#loginbt"),
			txt: '数据提交中,请稍后...',
			onsucc: function(result) {
				$.hidediv(result);
				if (parseInt(result['rcode']) > 0) {
					qr.gu({
						ubox: 'unm',
						rbox: 'innermsg',
						h3: 'h3',
						logo: 'userlogo'
					});
					try {
						PlayHistoryObj.viewPlayHistory('playhistory');
					} catch(e) {}
					$("#cboxClose").trigger('click');
					//登录后隐藏漂浮广告
					// IKF.removeAd();
					//判断是否显示其他资源
					// IKF.isOther();
					//是否收藏和订阅
					IKF.isRssFav();
					//判断站内外播放
					// IKF.setOut();
					//判断是否为站内外播放
					// IKF.usedSetPlay();
					//登录切换到CK播放器
					if(window.location.href.indexOf('/ac/') != -1 && window.location.href.indexOf('.html') != -1){
						if(playConfig.setting){
							Play(playConfig.pv,playConfig.playname);
						}
					}
				}else if(parseInt(result['rcode'])==-3){

				}
			}
		}).post({
			url: Root + 'index.php?s=user-login-index'
		});
		return false;
	}
},
//调用接口封装
pagegoo: function(url){
	$.ajax({
		url : url,
		success : function(data) {
			if(data.ajaxtxt != '') {
				if ($('#commbox li').length > 3)
					$("html,body").animate({
						scrollTop : $("#commbox").offset().top - 130
					}, 1000);

					$("#commbox").empty().html(data.ajaxtxt);
					$(".digg a").click(function(e) {
						IKF.opp($(this).attr('data'), $(this));
						return false ;
					});
					$(".reply").click(function(e) {
						var curid = $(this).attr('data-id');
						var curpid = $(this).attr('data-pid');
						var curtuid = $(this).attr('data-tuid');
						if (!IKF.checkcookie()) {
							IKF.login_form();
							return false;
						}else{
							if ($("#rep" + curid).html() != '') {
								$("#rep" + curid).html('');
							} else {
								$(".comms").html('');
								$("#rep" + curid).html($("#hidcommform").html());
								$("#rep"+ curid+ " #comm_pid").val(curpid); //顶级ID
								$("#rep"+ curid+ " #comm_id").val(curid); //回贴ID
								$("#rep"+ curid+ " #comm_tuid").val(curtuid); //回贴用户ID
								$("#rep"+ curid+ " #row_id").attr("data-id", curid)
								$("#rep"+ curid+ " .recm_id").attr("id",'reply_'+curid)
								$("#rep" + curid + " .sub").unbind();
								$("#rep" + curid + " .sub").click(function(e) {
									$("#rep"+ curid+ " #mcommform").qiresub({
										curobj : $("#rep"+ curid+ " .sub"),
										txt : '数据提交中,请稍后...',
										onsucc : function(result) {
											$.hidediv(result);
											if (parseInt(result['rcode']) > 0) {
												IKF.pagegoo(Root + "index.php?s=user-comm-get-id-"+Id+"-sid-"+Sid) ;
											}
										}
									}).post({
										url : Root + 'index.php?s=user-center-addrecomm'
									});
								});
							}
						}
					});
			} else {
				$("#commbox").html('<li class="kong">当前没有评论，赶紧抢个沙发！</li>');
			};
			$("#pages").html(data.pages);
			$("#pagetop").html(data.pagetop);

			if (data.star != undefined && data.star != null) {
				IKF.stars(data.star);
			};
			$(".commpage a").click(function(e) {
				var pagegourl = $(this).attr('href');
				IKF.pagegoo(pagegourl);
				return false;
			});

		},dataType : 'json'
	});
	return false;
},
opp: function(url, thisobj) {
	$.showfloatdiv({
		txt : '数据提交中...',
		cssname : 'loading'
	});
	$.get(url, function(r) {
		$.hidediv(r);
		if (parseInt(r.rcode) > 0) {
			thisobj.children('span').html(parseInt(thisobj.children('span').html()) + 1)
		}
	}, 'json');
},
starclass: function(pfnum){
	var pfclass = '';
	if(pfnum >= 50){
		pfclass = 'bigstar50';
	}else if(pfnum >= 45){
		pfclass = 'bigstar45';
	}else if(pfnum >= 40){
		pfclass = 'bigstar40';
	}else if(pfnum >= 35){
		pfclass = 'bigstar35';
	}else if(pfnum >= 30){
		pfclass = 'bigstar30';
	}else if(pfnum >= 35){
		pfclass = 'bigstar35';
	}else if(pfnum >= 20){
		pfclass = 'bigstar20';
	}else if(pfnum >= 15){
		pfclass = 'bigstar15';
	}else if(pfnum >= 10){
		pfclass = 'bigstar10';
	}else if(pfnum >= 5){
		pfclass = 'bigstar5';
	}else if(pfnum >= 0){
		pfclass = 'bigstar0';
	}
	return pfclass;
},
//评分算法
stars: function(r) {
	var curstars = parseInt(r.mystars),
		a = parseInt(r['curpingfen'].a),
		b = parseInt(r['curpingfen'].b),
		c = parseInt(r['curpingfen'].c),
		d = parseInt(r['curpingfen'].d),
		e = parseInt(r['curpingfen'].e);
	$("#pa").html(a + "人");
	$("#pb").html(b + "人");
	$("#pc").html(c + "人");
	$("#pd").html(d + "人");
	$("#pe").html(e + "人");

	$("#commnum").html(r['curpingfen'].num);
	$("#commnums").html(r['curpingfen'].num);
	var totalnum = a + b + c + d + e;
	var pam = ((a / totalnum) * 100).toFixed(1) + "%";
	var pbm = ((b / totalnum) * 100).toFixed(1) + "%";
	var pcm = ((c / totalnum) * 100).toFixed(1) + "%";
	var pdm = ((d / totalnum) * 100).toFixed(1) + "%";
	var pem = ((e / totalnum) * 100).toFixed(1) + "%";
	$('.d-juqing-star em').html(totalnum);
	if (totalnum > 0) {
		$("#pam").animate({"width":pam},500);
		$("#pbm").animate({"width":pbm},500);
		$("#pcm").animate({"width":pcm},500);
		$("#pdm").animate({"width":pdm},500);
		$("#pem").animate({"width":pem},500);
		$("#pam").parent().attr('title',pam);
		$("#pbm").parent().attr('title',pbm);
		$("#pcm").parent().attr('title',pcm);
		$("#pdm").parent().attr('title',pdm);
		$("#pem").parent().attr('title',pem);
	};

	if (r['hadpingfen'] != undefined && r['hadpingfen'] != null) {hadpingfen = 1;}
	var PFbai = r['curpingfen'].pinfen*10;
	if (PFbai > 0) {
		$("#rating-main").show();
		$("#rating-kong").hide();
		// $("#fenshu").animate({'width': parseInt(PFbai) + "%"});
		// $("#total").animate({'width': parseInt(PFbai) + "%"});
		var pfnum = parseInt(PFbai)/2;
		$('#d-star').addClass(IKF.starclass(pfnum));
		if(r['curpingfen'].pinfen === "10.0"){
			r['curpingfen'].pinfen = "10";
		}
		$('#d-fen').html(r['curpingfen'].pinfen);
	} else {
		$("#rating-main").hide();
		$("#rating-kong").show();
		$(".loadingg").addClass('nopingfen').html('暂无评分，赶快打分吧！');
	};
	IKF.isRssFav(r);
	if (curstars > 0) {
		var curnum = curstars - 1;
		$("ul.rating li:lt(" + curnum + ")").addClass("current");
		$("ul.rating li:eq(" + curnum + ")").addClass("current");
		$("ul.rating li:gt(" + curnum + ")").removeClass("current");
		var arr = new Array('很差', '较差', '还行', '推荐', '力荐');
		$("#ratewords").html(arr[curnum]);
	}
},
//未登录显示登录弹层
login_form: function() {
	$.colorbox({
		inline: true,
		href: "#login-dialog",
		width: '570px',
		height: '380px'
	});
},
//搜索
so: function(){
	var searchList = $('.search-list');
	var searchText =  $(".search-text1");
	var searchListUl = $('#search-list-ul');
	var slrInner = $('#slr-inner');
	var searchListLeft = $('.search-list-left');
	var searchListRight = $('.search-list-right');
	var dataText = '', timer, keyNum = 0;
	function lineHeight(){
		//获取左右高度来定线;
		var leftHeight = searchListLeft.height();
		var rightHeight = searchListRight.height();
		if ( leftHeight > rightHeight ) {
			searchListRight.removeClass('bls');
			searchListLeft.addClass('brs2');
		}else{
			searchListRight.addClass('bls');
			searchListLeft.removeClass('brs2');
		}
    }
    function searchUrl(name){
        return '/search/'+ name +'.html';
    }
	function searchvod(keyword,event){
		//获得输出的li数据的个数
		var searchListLiLen = $('#search-list-ul li').length;
		//keyNum数据函数
		function keyNumDataFun(){
			//keyNum为多少的时候那么就当前的添加样式
			$('#search-list-ul li').eq(keyNum).addClass('searchListUl').siblings().removeClass('searchListUl');
			//按上下键的时候对应相应的数据
			var keyNumData = '<a class="slr-inner-pic" href="'+ searchUrl(dataText[keyNum].name) +'"><img src="' + dataText[keyNum].pic + '" /><em>' + dataText[keyNum].gold + '</em></a><p>分类：' + dataText[keyNum].type + '</p><p class="actor-name">状态：' + dataText[keyNum].continu + '</p><p>开播：' + dataText[keyNum].year + '年</p>';
			slrInner.html(keyNumData);
			//搜索框显示上下键搜索的名字
			keyword.val(dataText[keyNum].name);
		}
		//上键选择的时候
		if(event.keyCode == 38){
			if ( keyNum == 0 ) {
				keyNum = searchListLiLen - 1;
			}else{
				--keyNum;
			}
			keyNumDataFun();
			$('#search-list-ul li').attr('style','');
			$('#search-list-ul li').eq(keyNum).css('background-color','#ccc');
			//下键选择的时候
		}else if(event.keyCode == 40){
			if ( keyNum == searchListLiLen - 1 ) {
				keyNum = 0;
			}else{
				++keyNum;
			}
			keyNumDataFun();
			$('#search-list-ul li').attr('style','');
			$('#search-list-ul li').eq(keyNum).css('background-color','#ccc');
		}else{
			//清除延时
			clearTimeout(timer);
			//先清空内容
			searchListUl.html('');
			//获取当前的val值来拉升数据
			var thisVal = encodeURI(keyword.val());
			if (thisVal == '') {
				searchList.hide();
				return;
			}
			$.ajax({
				type : "GET",
				url : '/index.php?s=home-search-s&q='+ thisVal +'&limit=10&timestamp=' + Math.random(),
				// dataType : "jsonp",
				// jsonp: 'callback',
				success : function(data){
					if(data.status == 1){
						data = data.data
						//获得data数据让上下键控制的时候好获取
						dataText = data;
						//获取对象的个数
						var dataLen = data.length;
						if (dataLen == 0 || thisVal == '') {
							searchList.hide();
						}else{
							searchList.show();
							//遍历所有的对象内容插入到相应内容中
							var mvLi = '',
								url = '';
							for(var i = 0 ; i < dataLen ; i++){
								//当名字为空的时候那么就显示为其它;
								mvLi += '<li><a href="'+ searchUrl(data[i].name) +'"><em class="mvName">' + data[i].name + '</em><span>' + data[i].type + '</span></a><i class="iconfont">&#xe61c;</i></li>';
								searchListUl.html(mvLi);
								//第一个先得到显示
								var slrInnerFirst = '<a class="slr-inner-pic" href="'+ searchUrl(data[0].name) +'"><img src="' + data[0].pic + '" /><em>'+ data[0].gold +'</em></a><p>分类：' + data[0].type + '</p><p class="actor-name">状态：' + data[0].continu + '</p><p>开播：' + data[0].year + '年</p>';
								slrInner.html(slrInnerFirst);
								//鼠标触发的时候执行的动作
								searchListUl.children().on('mouseover',function(){
									$(this).addClass('searchListUl').siblings().removeClass('searchListUl');
									//对应的索引
									var thisIndex = $(this).index();
									//搜索框显示对应的名字
									searchText.val(dataText[thisIndex].name);
									//keyNum要同步
									keyNum = thisIndex;
									//显示右边的内容
									var slrInnerChild = '<a class="slr-inner-pic" href="'+ searchUrl(data[thisIndex].name) +'"><img src="' + data[thisIndex].pic + '" /><em>'+ data[0].gold +'</em></a><p>分类：' + data[thisIndex].type +'</p><p class="actor-name">状态：'+ data[thisIndex].continu +'</p><p>开播：'+ data[thisIndex].year + '年</p>'
									slrInner.html(slrInnerChild);
									//调用等高度线条
									lineHeight();
								});
								//第一个添加样式
								$('#search-list-ul li:first-child').addClass('searchListUl');
								//当重新输出的时候，那么 keyNum 再次归零
								keyNum = 0;
							}
						}
					}
				}
			});
		}
	}
	searchText.bind('keyup',function(event){
		searchvod($(this),event);
	}).bind('blur',function(){
		//鼠标聚焦离开的时候来个延时
		timer = setTimeout(function(){
			searchList.hide();
		},200)
	}).bind('focus',function(event){
		searchvod($(this),event);
	});
},
//切换站内站外
// Setting: function(set){
// 	localStorage.playStyle = set;
// 	if(setting){
// 		playStyle = parseInt(localStorage.playStyle);
// 		var name = localStorage.playtabname;
// 		var vid = localStorage.playtabvid;
// 		Play(vid,name);
// 	}
// },
// usedSetPlay: function(){
// 	var setNum = parseInt(localStorage.playStyle) || 2;  //2 站外 1站内
// 	if(setNum === 2){
// 		$('.setting').removeClass('cur');
// 		$('.setting em').text('站外');
// 	}else if(setNum === 1){
// 		$('.setting').addClass('cur');
// 		$('.setting em').text('站内');
// 	}
// },
// onSetPlay: function(obj){
// 	obj.click(function(){
// 		if($(this).hasClass('cur')){
// 			IKF.Setting(2);
// 			$(this).find('em').text('站外');
// 			$(this).removeClass('cur');
// 		}else{
// 			IKF.Setting(1);
// 			$(this).find('em').text('站内');
// 			$(this).addClass('cur');
// 		}
// 	})
// },
showPop: function(time){
	var timer = null,
	$item = $('.d-item a,.d-item-list a'),
	$pop = $('.d-pop');
	$item.hover(function(){
		$pop.html('');
		var y = $(this).offset().top;
		var x = $(this).offset().left;
		var id = $(this).attr('data-id');
		var w = $(this).width();
		var s = ''
		if(id){
			if((1200-(1.2*x)) < w){
				x = x - 360;
				s = 'style="margin-right:15px;"';
			}else{
				x = x + w - 5;
			}
			timer = setTimeout(function(){
				$pop.css({'top': y,'left': x,'display':'block'});
				$.ajax({
					type : "GET",
					url : '/index.php?s=home-search-pop&q='+ id +'&timestamp=' + Math.random(),
					success : function(data){
						//console.log(data);
						var data = data.data[0];
						var html = '';
						var gold = data.gold*10/2;
						if(data.actor === null) data.actor = '';
						if(data.director === null) data.director = '';
						if(data.mcid === '未知') data.mcid = '';
						html += '<div class="d-box" '+ s +'><div class="d-popinfo"><h3><a href="'+ data.url +'">'+ data.name +'('+ data.year +')</a></h3><p class="rank"><span id="d-star" class="'+ IKF.starclass(gold) +'"></span><strong>'+ data.gold +'</strong></p><p class="meta mt10 clearfix"><span class="green">'+ data.time +'</span><a href="'+ data.list_url +'">' + data.list_name +'</a>'+ data.area + data.mcid + data.director + data.actor +'</p><p class="collect-area"><div class="detail-sect"><div class="interest-sect user-bt"><a class="sect-btn" id="wish" href="javascript:void(0);" data="/index.php?s=user-comm-savelove-id-'+ data.id +'-cid-'+ data.cid +'.html"><i class="iconfont">&#xe633;</i>收藏</a><div class="sect-show" style="display: none;"><a class="cancel" href="javascript:void(0);" val="0" id="cancelbt" data="/index.php?s=user-comm-dellove-id-'+ data.id +'-cid-'+ data.cid +'.html" ><i class="iconfont">&#xe633;</i>已收藏</a></div></div><div class="interest-rss user-bt"><a class="rss-btn sect-btn" id="dingyue" href="javascript:void(0);" data="/index.php?s=user-comm-saveremind-id-'+ data.id +'-cid-'+ data.cid +'.html"><i class="iconfont">&#xe60c;</i>订阅</a><div class="rss-show sect-show" style="display: none;"><a class="cancel" href="javascript:void(0);" val="0" data="/index.php?s=user-comm-delremind-id-'+ data.id +'-cid-'+ data.cid +'.html" id="delbt"><i class="iconfont">&#xe60c;</i>已订阅</a></div></div></div></p></div><p class="comment">'+ data.content +'</p></div>';
						$pop.html(html);
						IKF.pagegoo(IKF.starUrl(data.id));
						IKF.clickRss();
					}
				});
			},time)
		}
	},function(){
		clearTimeout(timer);
		$pop.hide();
	});
	$pop.hover(function(){
		$(this).show();
	},function(){
		$(this).hide();
	});
}
}

$.extend({
	refresh : function(url) {
		window.location.href = url;
	}
});
function getEvent() {
	if (document.all) return window.event;
	func = getEvent.caller;
	while (func != null) {
		var arg0 = func.arguments[0];
		if (arg0) {
			if ((arg0.constructor == Event || arg0.constructor == MouseEvent)
					|| (typeof (arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)) {
				return arg0;
			}
		}
		func = func.caller;
	}
	return null;
}
jQuery.showfloatdiv = function(ox) {
	var oxdefaults = {
		txt : '数据加载中,请稍后...',
		classname : 'progressBar',
		left : 410,
		top : 210,
		wantclose : 1,
		suredo : function(e) {
			return false;
		},
		succdo : function(r) {},
		completetxt : '操作成功!',
		autoclose : 1,
		ispost : 0,
		cssname : 'alert',
		isajax : 0,
		intvaltime : 1000,
		redirurl : '/'
	};
	ox = ox || {};
	$.extend(oxdefaults, ox);
	$("#tbmovbox_overlay").remove();
	$("#tbmovbox").remove();
	if (oxdefaults.wantclose == 1) {
		var floatdiv = $('<div class="tbmovbox-overlayBG" id="tbmovbox_overlay"></div><div id="tbmovbox" class="tbmovbox png-img"><iframe frameborder="0" class="ui-iframe"></iframe><table class="ui-dialog-box"><tr><td><div class="ui-dialog"><div class="ui-dialog-cnt" id="ui-dialog-cnt"><div class="ui-dialog-tip alert" id="ui-cnt"><span id="xtip">'
				+ oxdefaults.txt
				+ '</span></div></div><div class="ui-dialog-close"><span class="close">关闭</span></div></div></td></tr></table></div>');
		$("body").append(floatdiv);
		$("#tbmovbox_overlay").fadeIn(500);
		$("#tbmovbox").fadeIn(500);
		$("#ui-cnt").removeClass('succ error alert loading').addClass(
				oxdefaults.cssname);
		$(".ui-dialog-close").click(function() {
			$.closefloatdiv();
		});
		if (oxdefaults.isajax == 1) {
			objEvent = getEvent();
			if (objEvent.srcElement)
				id = objEvent.srcElement;
			else
				id = objEvent.target;
			var idval = (id.attributes["data"].nodeValue != null && id.attributes["data"].nodeValue != undefined) ? id.attributes["data"].nodeValue
					: id.data;
			$.ajax({
				url : idval,
				async : true,
				type : 'get',
				cache : true,
				dataType : 'json',
				success : function(data, textStatus) {
					if (data.msg != null && data.msg != undefined) {
						$("#xtip").html(data.msg);
					} else {
						$("#xtip").html(oxdefaults.completetxt);
					}
					oxdefaults.succdo(data);
					if (data.wantclose != null && data.wantclose != undefined) {
						$.hidediv(data);
					} else if (oxdefaults.autoclose == 1) {
						$.hidediv(data);
					}
					if (data.wantredir != undefined || data.wantredir != null) {
						if (data.redir != undefined || data.redir != null) {
							setTimeout("$.refresh('" + data.redir + "')",
									oxdefaults.intvaltime);
						} else {
							setTimeout("$.refresh('" + oxdefaults.redirurl
									+ "')", oxdefaults.intvaltime);
						}
					}
				},
				error : function(e) {
					$("#xtip").html('系统繁忙,请稍后再试...');
				}
			});
		}
	} else if (oxdefaults.wantclose == 2) {
		objEvent = getEvent();
		if (objEvent.srcElement)
			id = objEvent.srcElement;
		else
			id = objEvent.target;
		var idval = (id.attributes["data"].nodeValue != null && id.attributes["data"].nodeValue != undefined) ? id.attributes["data"].nodeValue
				: id.data;
		var floatdiv = $('<div class="tbmovbox-overlayBG" id="tbmovbox_overlay"></div><div id="tbmovbox" class="tbmovbox png-img"><iframe frameborder="0" class="ui-iframe"></iframe><table class="ui-dialog-box"><tr><td><div class="ui-dialog"><div class="ui-dialog-cnt" id="ui-dialog-cnt"><div class="ui-dialog-tip alert" id="ui-cnt"><span id="xtip">'
				+ oxdefaults.txt
				+ '</span></div></div><div class="ui-dialog-todo"><a class="ui-link ui-link-small" href="javascript:void(0);" id="surebt">确定</a><a class="ui-link ui-link-small cancelbt"  id="cancelbt">取消</a><input type="hidden" id="hideval" value=""/></div><div class="ui-dialog-close"><span class="close">关闭</span></div></div></td></tr></table></div>');
		$("body").append(floatdiv);
		$("#tbmovbox_overlay").fadeIn(500);
		$("#tbmovbox").fadeIn(500);
		$(".ui-dialog-close").click(function() {
			$.closefloatdiv();
		});
		$(".cancelbt").click(function() {
			$.closefloatdiv();
		});
		$("#surebt").click(function(e) {
		if (!oxdefaults.suredo(e)) {
			$(".ui-dialog-todo").remove();
			$("#ui-cnt").removeClass('succ error alert').addClass('loading');
			if (oxdefaults.ispost == 0){
				if(idval == "1"){
					return true ;
				}
				$.ajax({
					url : idval.indexOf("index.php") <= 0 ? "/index.php" + idval.split("/")[1] : idval,
					async : true,
					type : 'get',
					cache : true,
					dataType : 'json',
					success : function(data,textStatus) {
						if (data.msg != null && data.msg != undefined) {
							$("#xtip").html(data.msg);
						}else{
							$("#xtip").html(oxdefaults.completetxt);
						}
						oxdefaults.succdo(data);
						if (data.wantclose != null && data.wantclose != undefined) {
							$.hidediv(data);
						} else if (oxdefaults.autoclose == 1) {
							$.hidediv(data);
						}
					},error : function(e) {
						$("#xtip").html('系统繁忙,请稍后再试...');
					}
				});
			} else {
				$("#" + oxdefaults.formid).qiresub({
					curobj : $("#surebt"),
					txt : '数据提交中,请稍后...',
					onsucc : function(result) {
						oxdefaults.succdo(result);
						$.hidediv(result);
					}
				}).post({
					url : oxdefaults.url
				});
			}
		} else {
			oxdefaults.succdo(e);
		}
	});
	} else {
		var floatdiv = $('<div class="tbmovbox_overlayBG" id="tbmovbox_overlay"></div><div id="tbmovbox" class="tbmovbox"><iframe frameborder="0" class="ui-iframe"></iframe><div class="ui-dialog"><div class="ui-dialog-cnt" id="ui-dialog-cnt"><div class="ui-dialog-box"<div class="ui-cnt" id="ui-cnt">'
				+ oxdefaults.txt + '</div></div></div></div></div>');
		$("body").append(floatdiv);
		$("#tbmovbox_overlay").fadeIn(500);
		$("#tbmovbox").fadeIn(500);
	}
	$('#tbmovbox_overlay').bind('click', function(e) {
		$.closefloatdiv(e);
		if (pp != null) {
			clearTimeout(pp);
		}
	});
};
jQuery.closefloatdiv = function(e) {
	$("#tbmovbox_overlay").remove();
	$("#tbmovbox").remove();
};
jQuery.hidediv = function(e) {
	var oxdefaults = {
		intvaltime : 1000
	};
	e = e || {};
	$.extend(oxdefaults, e);
	if (e.msg != null && e.msg != undefined) {
		$("#ui-cnt").html(e.msg);
	}
	if (parseInt(e.rcode) == 1) {
		$("#ui-cnt").removeClass('loading error alert').addClass('succ');
	} else if (parseInt(e.rcode) < 1) {
		$("#ui-cnt").removeClass('loading alert succ').addClass('error');
	}
	pp = setTimeout("$.closefloatdiv()", oxdefaults.intvaltime);
};
(function($) {
	$.fn.qiresub = function(options) {
		var defaults = {
			txt : '数据提交中,请稍后...',
			redirurl : window.location.href,
			dataType : 'json',
			onsucc : function(e) {},
			onerr : function() {
				$.hidediv({
					msg : '系统繁忙'
				});
			},
			oncomplete : function() {},
			intvaltime : 1000
		};
		options.curobj.attr('disabled', true);
		var ox = options.curobj.offset();
		var options = $.extend(defaults, options);
		$.showfloatdiv({
			offset : ox,
			txt : defaults.txt
		});
		var obj = $(this);
		var id = obj.attr('id');
		return {
			post: function(e) {
				$("#ui-cnt").removeClass('succ error alert').addClass('loading');
				$.post(e.url, obj.serializeArray(), function(result) {
					options.curobj.attr('disabled', false);
					defaults.onsucc(result);
					if (result.closediv != undefined || result.closediv != null) {
						$.closefloatdiv();
					}
					if (result.wantredir != undefined || result.wantredir != null) {
						if (result.redir != undefined || result.redir != null) {
							setTimeout("$.refresh('" + result.redir+ "')", options.intvaltime);
						} else {
							setTimeout("$.refresh('" + options.redirurl+ "')", options.intvaltime);
						}
					}
		  		}, options.dataType).error(function() {
					options.curobj.attr('disabled', false);
					defaults.onerr();
				}).complete(function() {
					defaults.oncomplete();
					options.curobj.attr('disabled', false);
				});
			},
			implodeval : function(e) {
				val = $("#" + id + " :input").map(function() {
					if ($(this).attr('name') != '' && $(this).attr('name') != undefined) {
						return $(this).attr('name') + "-" + $(this).val();
					}
				}).get().join("-");
				return val;
			},
			get : function(e) {
				$(".ui-dialog-todo").remove();
				$("#ui-cnt").removeClass('succ error alert').addClass('loading');
				var val = this.implodeval();
				$.get( e.url + "-" + val, '', function(result) {
					options.curobj.attr('disabled', false);
					defaults.onsucc(result);
					if (result.wantredir != undefined || result.wantredir != null) {
						if (result.redir != undefined || result.redir != null) {
							setTimeout("$.refresh(" + result.redir + ")", options.intvaltime);
						} else {
							setTimeout("$.refresh(" + options.redirurl + ")", options.intvaltime);
						}
					}
				}, options.dataType).error(function() {
					options.curobj.attr('disabled', false);
					defaults.onerr();
				}).complete(function() {
					defaults.oncomplete();
					options.curobj.attr('disabled', false);
				});
			}
		};
	};
})(jQuery);
var qruser;
var loginhtml;
function qireuser() {};
qireuser.prototype.urls = new Array(Root + 'index.php?s=user-home-flushinfo', Root + 'index.php?s=User-Center-getremindnew');

qireuser.prototype.gu = function(e) {
	$.get(Root + 'index.php?s=user-home-flushinfo', '', function(result) {
		if(result != null && result != undefined){
			if (parseInt(result.rcode) == -7) {
				$.showfloatdiv({
					txt: result.msg,
					classname: 'error'
				});
				$.hidediv({
					rcode: -1,
					msg: result.msg
				});
				return false;
			}
			if (result.uid > 0) {
				qruser = result;
				if (parseInt(result.history) > 5) {
					$("#morelog").html('<a target="_blank" href="'+ Root +'index.php?s=user-center-playlog">查看我的播放记录&gt;&gt;</a>');
					$("#morelog").show();
				} else {
					$("#morelog").html('');
					$("#morelog").hide();
				}
				loginhtml = $("#loginbarx").html();
				$("#loginbarx").html(result.html);
				$("#loginbar").hide();
				$(".logoutbt").unbind();
				$(".logoutbt").click(function(e) {
					$.showfloatdiv({
						txt: '正在退出...',
						cssname: 'loading',
						isajax: 1,
						succdo: function(r) {
							IKF.clearcookie();
							try {
								PlayHistoryObj.viewPlayHistory('playhistory');
							} catch(e) {}
							r.wantredir = null;
							$("#loged").html('');
							$("#innermsg").html('登录');
							$("#loginbar").show();
							$("#loginbarx").html(loginhtml);
							$("#loginform #loginbt").click(function(e) {
								try {
									IKF.userlogin();
								} catch(e) {}
							});
							window.location.href = window.location.href;
						}
					});
					return false;
				});
			}
		}
	}, 'json');
};
qireuser.prototype.gr = function() {
	$.get(this.urls[1] + '-' + this.parms[1], '', function(result) {
		this.r = result;
		if (parseInt(result[0])) {
			$("#" + e.rbox).html('订阅更新<strong>(' + result[0] + ')</strong>');
		}
	}, 'jsonp');
}
qireuser.prototype.ucenter = function() {}
var qr = new qireuser();
if (IKF.checkcookie()) {
	qr.gu({
		ubox: 'unm',
		rbox: 'innermsg',
		h3: 'h3',
		logo: 'userlogo'
	});
}
function gqq() {
	qr.ucenter();
}
Date.prototype.pattern = function(fmt) {
	var o = {
		"M+": this.getMonth() + 1,
		"d+": this.getDate(),
		"h+": this.getHours() == 0 ? 12: this.getHours(),
		"H+": this.getHours(),
		"m+": this.getMinutes(),
		"s+": this.getSeconds(),
		"q+": Math.floor((this.getMonth() + 3) / 3),
		"S": this.getMilliseconds()
	};
	var week = {
		"0": "\u65e5",
		"1": "\u4e00",
		"2": "\u4e8c",
		"3": "\u4e09",
		"4": "\u56db",
		"5": "\u4e94",
		"6": "\u516d"
	};
	if (/(y+)/.test(fmt)) {
		fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	}
	if (/(E+)/.test(fmt)) {
		fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "\u661f\u671f": "\u5468") : "") + week[this.getDay() + ""]);
	}
	for (var k in o) {
		if (new RegExp("(" + k + ")").test(fmt)) {
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
		}
	}
	return fmt;
}

$("#loginform #loginbt").click(function(e) {
	IKF.userlogin();
});

//观看记录
function PlayHistoryClass() {
	var cookieStr, nameArray, urlArray, allVideoArray;
	this.getPlayArray = function() {
		cookieStr = document.cookie;
		var start = cookieStr.indexOf("pp_vod_v=") + "pp_vod_v=".length, end = cookieStr
				.indexOf("_$_|", start), allCookieStr = unescape(cookieStr
				.substring(start, end))
		if (end == -1) {
			allCookieStr = "";
			return;
		}
		allVideoArray = allCookieStr.split("_$_");
		nameArray = new Array(), urlArray = new Array();
		for ( var i = 0; i < allVideoArray.length; i++) {
			var singleVideoArray = allVideoArray[i].split("^");
			nameArray[i] = singleVideoArray[0];
			urlArray[i] = singleVideoArray[1];
		}
	}
	this.viewPlayHistory = function(div) {
		var tag = document.getElementById(div), n = 12;
		if(IKF.checkcookie()){
			$.get(Root +"index.php?s=User-Comm-getplaylog", function(result){
				if(result['rcode']>-1){
					$("#his-todo").hide();
					if(result['r']!=null&&result['r'].length>0){
						innerStr='';
						for(var i in result['r']){
							var data = result['r'][i];

							innerStr += "<li><h5><a href=\"" + data['vod_readurl']
									+ "\">"+data['vod_name']
									+"</a><em>/</em><a href='"
									+data['vod_palyurl']+"' target='_blank'>"
									+data['url_name']+"</a></h5><label><a class=\"color\" href=\""
									+ data['vod_palyurl'] + "\">继续观看</a></label><a href=\"javascript:;\" target='_blank' class='delck' data=\""
									+data['id']+"\" mtype='ajax'>删除</a></li>" ;
						}
						if (innerStr.length>0){
							$("#emptybt").unbind();
							$("#emptybt").click(function(){
								PlayHistoryObj.emptyhistory('ajax');
								return false;
							});
							tag.innerHTML= innerStr;
							$(".delck").click(function(e){
								PlayHistoryObj.removeHistory($(this).attr('data'),$(this).attr('mtype'));
								$(this).parent('li').remove();
								return false;
							});
						}
					}else{
						document.getElementById('playhistory').innerHTML="<li class='no-his'><p>暂无播放历史列表...</p></li>";
					}
				}
			},'json');
			$("#his-todo").hide();
		}


		if (navigator.cookieEnabled) {
			var innerStr = "";
			if (nameArray != undefined && nameArray != null) {
				for ( var i = nameArray.length - 1; i >= 0; i--) {
					var vodnames = nameArray[i].split('|');
					var vodlinks = urlArray[i].split('|');
					if (vodnames.length == 2 && vodlinks.length ==2) {
						innerStr += "<li><h5><a href=\""
								+ vodnames[1]
								+ "\">"
								+ vodnames[0]
								+ "</a><em>/</em><a target='_blank' href=\""
								+ vodlinks[1]
								+"\">"
								+ vodlinks[0]
								+"</a></h5><label><a class=\"color\" target='_blank' href=\""
								+ vodlinks[1]
								+ "\">继续观看</a></label><a href=\"javascript:;\" class='delck' data='"
								+ i + "' mtype='inck'>删除</a></li>"
					}
				}
			}
			$("#his-todo").show();
			$("#morelog").hide();
			if (innerStr.length > 0) {
				$("#emptybt").unbind();
				$("#emptybt").click(function() {
					PlayHistoryObj.emptyhistory('ck');
					return false;
				});
				tag.innerHTML = innerStr;
				$(".delck").click(function(e) {
					if (PlayHistoryObj.removeHistory($(this).attr('data'), $(this).attr('mtype'))) {
						$(this).parent('li').remove();
						return false;
					}
				});
			} else {
				document.getElementById('playhistory').innerHTML = "<li class='no-his'><p>暂无播放历史列表...</p></li>";
			}
		} else {
			set(tag, "您浏览器关闭了cookie功能，不能为您自动保存最近浏览过的网页。")
		}
	}
	this.removeHistory = function(ii, type) {
		this.getPlayArray();
		if (type == 'inck') {
			var count = 10; // 播放历史列表调用条数
			expireTime = new Date(new Date().setDate(new Date().getDate() + 30));
			timeAndPathStr = "|; expires=" + expireTime.toGMTString() + "; path=/";
			if (cookieStr.indexOf("pp_vod_v=") != -1 || cookieStr.indexOf("_$_|") != -1) {
				var newCookieStr = "";
				for (i in allVideoArray) {
					if (i != ii) {
						newCookieStr += escape(nameArray[i]) + "^" + escape(urlArray[i]) + "_$_";
					}
				}
				document.cookie = "pp_vod_v=" + newCookieStr + timeAndPathStr;
				return true;
			}
			return false;
		}else{
			$.get(Root + 'index.php?s=User-Comm-delplaylog',{id:ii},function(r){},'json');
		}
	}
	this.addPlayHistory = function(json,vod_readurl,vod_palyurl) {
		var count = 10; // 播放历史列表调用条数
		if(IKF.checkcookie()){
			$.post(Root + "index.php?s=User-Comm-addplaylog",json);
		}
		var name = json.vod_name+"|" + vod_readurl ;
		var url = json.url_name  +"|" + vod_palyurl ;

		var code_name = escape(name) + "^", code_url = escape(url) + "_$_",
		expireTime = new Date(new Date().setDate(new Date().getDate() + 30)), timeAndPathStr = "|; expires="+ expireTime.toGMTString() + "; path=/";


		if ((cookieStr.indexOf("pp_vod_v=") != -1 || cookieStr.indexOf("_$_|") != -1) && allVideoArray != undefined) {
			var newCookieStr = "";
			if (allVideoArray.length < count) {
				for (i in allVideoArray) {
					if(nameArray[i] != name) {
						newCookieStr += escape(nameArray[i]) + "^" + escape(urlArray[i]) + "_$_";
					}
				}
			} else {
				for ( var i = 1; i < count; i++) {
					if (nameArray[i] != name) {
						newCookieStr += escape(nameArray[i]) + "^" + escape(urlArray[i]) + "_$_";
					}
				}
			}
			document.cookie = "pp_vod_v=" + newCookieStr + code_name + code_url + timeAndPathStr;
		} else {
			document.cookie = "pp_vod_v=" + code_name + code_url + timeAndPathStr;
		}
	}

	this.emptyhistory = function(type){
		$.showfloatdiv({
			txt : '确定删除？',
			wantclose : 2,
			suredo : function(e) {
				if(type=='ajax'){
					$.get(Root + 'index.php?s=User-Comm-emptyhistory',function(r){document.getElementById('playhistory').innerHTML="<li class='no-his'><p>暂无播放历史列表...</p></li>";});
				}else{
					_GC();
				}
				$.closefloatdiv();
				return true;
			}
		});
		return false;
	}
}
function _GC() {
	document.getElementById('playhistory').innerHTML = "<li class='no-his'><p>暂无播放历史列表...</p></li>";
	var expdate = new Date(1970, 1, 1);
	document.cookie = "pp_vod_v=; path=/";
}
var PlayHistoryObj = new PlayHistoryClass()
PlayHistoryObj.getPlayArray();

//退出
$(".logoutbt").click(function(e) {
$.showfloatdiv({
	txt: '正在退出...',
	cssname: 'loading',
	isajax: 1,
	succdo: function(r) {
		setTimeout("$.refresh('index.php?s=user-login-index')",500);
	}
});
return false;
});

$("#up,#down").click(function(e) {
	IKF.opp($(this).attr('data'), $(this));
	return false ;
});

$("#qqlogin,#weibologin").click(function(e) {
var url = $(this).attr("url");
var t = $(this).attr("t");
if(t==1){
 window.open(url,"_blank","width=750, height=425");
}
 setTimeout(function(){
	qr.gu({ubox: "unm",rbox: "innermsg",h3: "h3",logo: "userlogo"});
	try {
		PlayHistoryObj.viewPlayHistory("playhistory")
	} catch (b) {}
	$("#cboxClose").trigger("click")
 },5000)
});

$("#comm_txt").focus(function(e) {
if (!IKF.checkcookie()) {
	IKF.login_form();
	return false;
}
});
$("#loginbarx, #nav-looked").click(function(e) {
if (!IKF.checkcookie()) {
	IKF.login_form();
	return false;
}
});
$("#subcomm").click(function(e) {
	$("#commform").qiresub({
		curobj : $("#subcomm"),
		txt : '数据提交中,请稍后...',
		onsucc : function(result) {
			$.hidediv(result);
			if (parseInt(result['rcode']) > 0) {
				IKF.pagegoo(IKF.starUrl($("#_void_id").val())) ;
			}
		}
	}).post({
		url : Root + 'index.php?s=user-center-addcomm'
	});
	return false;
});
$("#indexlogin,#indexreg").click(function() {
	$("#indexlogin,#indexreg").attr('src', "index.php?s=user-login-verify-" + Math.random());
});
$("#register").click(function(e) {
	IKF.userreg();
});
$("#qqlogin").click(function(e) {
	setTimeout(function(){
		window.location.reload();
	},7000)
});
$("ul.rating li").click(function(e) {
	$("#rating").qiresub({
		curobj : $("ul.rating li"),
		onsucc : function(result) {
			$.hidediv(result);

			IKF.pagegoo(IKF.starUrl($("#_void_id").val()));
		}
	}).post({
		url : IKF.starUrl($("#_void_id").val())
	});
	return false;
});


if (Id != undefined && Id != null && Id != '' && Cm != undefined && Cm != null && Cm != '') {
IKF.pagegoo(IKF.starUrl(Id));
};

//图片延时加载
;(function($) {
$.fn.scrollLoading = function(options) {
	var defaults = {
		attr: "data-original",
		container: $(window),
		callback: $.noop
	};
	var params = $.extend({}, defaults, options || {});
	params.cache = [];
	$(this).each(function() {
		var node = this.nodeName.toLowerCase(), url = $(this).attr(params["attr"]);
		//重组
		var data = {
			obj: $(this),
			tag: node,
			url: url
		};
		params.cache.push(data);
	});

	var callback = function(call) {
		if ($.isFunction(params.callback)) {
			params.callback.call(call.get(0));
		}
	};
	//动态显示数据
	var loading = function() {

		var contHeight = params.container.height();
		if (params.container.get(0) === window) {
			contop = $(window).scrollTop();
		} else {
			contop = params.container.offset().top;
		}
		$.each(params.cache, function(i, data) {
			var o = data.obj, tag = data.tag, url = data.url, post, posb;

			if (o) {
				post = o.offset().top - contop, posb = post + o.height();
				if ((post >= 0 && post < contHeight) || (posb > 0 && posb <= contHeight)) {
					if (url) {
						//在浏览器窗口内
						if (tag === "img") {
							//图片，改变src
							callback(o.attr("src", url));
						} else {
							o.load(url, {}, function() {
								callback(o);
							});
						}
					} else {
						// 无地址，直接触发回调
						callback(o);
					}
					data.obj = null;
				}
			}
		});
	};
	//事件触发
	//加载完毕即执行
	loading();
	//滚动执行
	params.container.bind("scroll", loading);
};
})(jQuery);

//更多剧集方法
var WidthScreen = true;
function series(div,n1,n2){
var len = div.find("a").length;
var n = WidthScreen ? n1:n2;
if(len>100){    //超过100集时的方法
	var Nps = Math.ceil(len/100);    //得出百的倍数
	for(var i=0;i<Nps;i++){    //添加节点n个百集节点
		div.append("<div class='fortab'></div>");
	}
	for(var j=1;j<=Nps;j++){    //将所有剧集移到对应的fortab节点
		var ln = j==Nps ? len-Nps*100+100:100;
		div.find("a:lt("+ln+")").appendTo(div.find(".fortab").eq(j-1));
	}
	if(typeof TooLength != "undefined"){TooLength++;}    //增加太长id号
	else{window.TooLength = 1;}    //未定义id号是设为1
	$("body").append("<div class='Df' id='TooLength"+TooLength+"' style='display:none'></div>");    //添加id节点，将移入div用来默认显示
	div.find("a:lt("+(n2+18)+")").clone().appendTo($("#TooLength"+TooLength));    //添加前面集数
	div.find("a:gt("+(len-((n1/2)-2)/2-1)+")").clone().appendTo($("#TooLength"+TooLength));    //添加后面几集
	$("#TooLength"+TooLength).prependTo(div);    //默认显示id移入div
	div.find(".Df").show();
	var opBtn = "<a target='_self' href='javascript:void(0)' class='more Open'>更多剧集<i class=\"iconfont\">&#xe621;</i></a>";    //给默认显示盒加个open按钮
	div.find(".Df a").eq(n2+17).after(opBtn);    //添加open按钮
	var closeBtn = "<a target='_self' href='javascript:void(0)' class='more Close'>收&nbsp;&nbsp;起<i class=\"iconfont\">&#xe609;</i></a>";
	for(var k=0;k<Nps;k++){div.find(".fortab").eq(k).append(closeBtn);}    //给所有fortab盒子加close按钮
	var Navs = "<div class='Navs clearfix' style='display:none;'>";    //创建第n-n+100的导航栏节点
	for(var l=0;l<Nps;l++){
		var min = l*100+1;
		var max = l==Nps-1 ? len:(l+1)*100;
		if(l==0){Navs += "<a target='_self' href='javascript:void(0)' class='more active'>"+min+"-"+max+"</a>";}
		else{Navs += "<a target='_self' href='javascript:void(0)' class='more'>"+min+"-"+max+"</a>";}
	}
	Navs += "</div>";
	div.find(".Df").after(Navs);    //添加导航节点，html结构到此完善
	var showPg = 0;    //默认页为0,即第一页，下面的是方法
	var DfBox = div.find(".Df");
	var navBox = div.find(".Navs");
	var tabBox = div.find(".fortab");
	div.find(".Open").click(function(){
		DfBox.hide();
		navBox.show();
		tabBox.eq(showPg).show();
	});
	div.find(".Close").click(function(){
		DfBox.show();
		navBox.hide();
		tabBox.eq(showPg).hide();
	});
	div.find(".Navs a").click(function(){
		if($(this).hasClass("active")) return;
		var _i = $(this).index();
		tabBox.eq(showPg).hide();
		tabBox.eq(_i).show();
		$(this).addClass("active").siblings(".active").removeClass("active");
		showPg = _i;
	})
	div.css("height","auto");
}else if(len>n){
	for(var i=n2+18;i<(len-((n1/2)-2)/2);i++){div.find("a").eq(i).addClass("Hide");}
	var t_m = "<a target='_self' href='javascript:void(0)' class='more'>更多剧集<i class=\"iconfont\">&#xe621;</i></a>";
	div.find("a").eq(n2+17).after(t_m);
	var more = div.find(".more");
	var _open = false;
	div.css("height","auto");
	more.click(function(){
		if(_open){
			div.find(".Hide").hide();
			$(this).html("更多剧集");
			$(this).append('<i class="iconfont">&#xe621;</i>');
			$(this).insertAfter(div.find("a").eq(n2+17));
			_open = false;
		}else{
			div.find(".Hide").show();
			$(this).html("收&nbsp;&nbsp;起");
			$(this).append('<i class="iconfont">&#xe609;</i>');
			$(this).insertAfter(div.find("a:last"));
			_open = true;
		}
	})
}
}
//Tab切换
function setTab(a,b,c){var d,e;for(i=1;c>=i;i++)d=document.getElementById(a+i),e=document.getElementById("con_"+a+"_"+i),d.className=i==b?"current":"",e.style.display=i==b?"block":"none"}

$(document).ready(function(){
/**表情***/
if ($(".emotion").length > 0) {
	$(document).on('click', '.emotion', function(){
		var left = $(this).offset().left;
		var top = $(this).offset().top;
		var id = $(this).attr("data-id");
		$("#smileBoxOuter").css({
			"left": left,
			"top": top + 20
		}).show().attr("data-id", id)
	});
	$("#smileBoxOuter,.emotion").hover(function() {
		$("#smileBoxOuter").attr("is-hover", 1)
	},function() {
		$("#smileBoxOuter").attr("is-hover", 0)
	});
	$(".emotion,#smileBoxOuter").blur(function() {
		var is_hover = $("#smileBoxOuter").attr("is-hover");
		if (is_hover != 1) {
			$("#smileBoxOuter").hide()
		}
	});
	$(".smileBox").find("a").click(function() {
		var textarea_id = $("#smileBoxOuter").attr("data-id");
		var textarea_obj = $("#reply_" + textarea_id).find("textarea");
		var textarea_val = textarea_obj.val();
		if (textarea_val == "发布评论") {
			textarea_obj.val("")
		}
		var title = "[" + $(this).attr("title") + "]";
		textarea_obj.val(textarea_obj.val() + title).focus();
		$("#smileBoxOuter").hide()
	});
	$("#smileBoxOuter").find(".smilePage").children("a").click(function() {
		$(this).addClass("current").siblings("a").removeClass("current");
		var index = $(this).index();
		$("#smileBoxOuter").find(".smileBox").eq(index).show().siblings(".smileBox").hide()
	});
	$(".comment_blockquote").hover(function() {
		$(".comment_action_sub").css({
			"visibility": "hidden"
		});
		$(this).find(".comment_action_sub").css({
			"visibility": "visible"
		})
	}, function() {
		$(".comment_action_sub").css({
			"visibility": "hidden"
		})
	})
}
$("#cmt-input-tip .ui-input").focus(function(){
	$("#cmt-input-tip").hide();
	$("#cmt-input-bd").show();
	$("#cmt-input-bd .ui-textarea").focus();
});
//搜索框下拉更多
if ($(".search-text1").get(0)) {
	IKF.so()
}
//如果已经登录自动跳转到首页
if(IKF.checkcookie()){
	if(locationURL.indexOf('user-center-login.html') != -1 || locationURL.indexOf('user-center-reg.html') != -1){
		window.location.href = window.location.origin;
	}
}else{
	//判断是不是禁片
	if(noLogin === 'stop' || noLogin === 'stop-vip'){
		window.location.href = window.location.origin + '/hexie.html';
	}
}
//回到顶部
$(window).scroll(function(){
	if ($(window).scrollTop()>100){
		$("#back-to-top").fadeIn(100);
	}else{
		$("#back-to-top").fadeOut(100);
	}
});
$("#back-to-top").click(function(){
	$('body,html').animate({scrollTop:0},100);
	return false;
});

// drop-down
$(".drop-down").hover(function(){
	clearTimeout(timer);
	$(".drop-box").hide();
	$(this).find(".drop-title").addClass("drop-title-hover");
	$(this).find(".drop-box").show();
},function(){
	$(this).find(".drop-title").removeClass("drop-title-hover");
	timer = setTimeout($.proxy(function() {
		$(this).find(".drop-box").hide();
	}, this),300);
});
$(document).click(function () {$('.drop-box').hide()});
$('.drop-box').click(function (event) { event.stopPropagation();$(this).show()});
// 评分
$("ul.rating li").each(function(i){
	var $title = $(this).attr("title");
	var $lis = $("ul.rating li");
	var num = $(this).index();
	var n = num+1;
	$(this).click(function(){
		if(hadpingfen>0){
			$.showfloatdiv({txt:'已经评分,请务重复评分'});
			$.hidediv({});
		}else{
			$.showfloatdiv({txt:'数据提交中...',cssname:'loading'});
			$lis.removeClass("active");
			$("ul.rating li:lt("+n+")").addClass("active");
			$("#ratewords").html($title);
			$.post(Root + 'index.php?s=user-comm-mark',
				{'val':$(this).attr('val'),'id':$("#_void_id").val()},
				function(r){
					if(parseInt(r.rcode)>0){
						$.hidediv(r);
						hadpingfen=1;
					}else{
						if(parseInt(r.rcode)==-2){
							hadpingfen=1;
							$.showfloatdiv({txt:'已经评分,请务重复评分'});
							$.hidediv({});
						}else{
							$.closefloatdiv();
							$("#innermsg").trigger('click');
						}
					}
			},'json');
		}
	}).hover(function(){
		this.myTitle=this.title;
		this.title="";
		$(this).nextAll().removeClass("active");
		$(this).prevAll().addClass("active");
		$(this).addClass("active");
		$("#ratewords").html($title);
	},function(){
		this.title=this.myTitle;
		$("ul.rating li:lt("+n+")").removeClass("hover");
	});
});
//判断当前频道高亮
if(locationURL.indexOf('/ac/') > 0 && locationURL.indexOf('/news/') <= 0){
	$('.d-vod-title .gaikuang').eq(0).addClass('cur');
}else if(locationURL.indexOf('/actor/') > 0){
	$('.d-vod-title .shengyou').eq(0).addClass('cur');
}else if(locationURL.indexOf('/news/') > 0 || locationURL.indexOf('/article/') > 0){
	$('.d-vod-title .news').eq(0).addClass('cur');
}else if(locationURL.indexOf('/plot/') > 0){
	$('.d-vod-title .juqing').eq(0).addClass('cur');
}else if(locationURL.indexOf('/time/') > 0){
	$('.d-vod-title .time').eq(0).addClass('cur');
}

$(".focus,.ated").click(function(e) {
	$.showfloatdiv({
		txt: '数据提交中...',
		cssname: 'loading'
	});
	var obj = $(this);
	$.ajax({
		url: obj.attr('data'),
		success: function(r) {
			$.hidediv(r);
			if (parseInt(r.rcode) > 0) {
				if (r.docode == 2) {
					obj.removeClass('ated').addClass('focus').html('+关注').attr('data','/user-userdo-focususer-uid-'+obj.attr('val'));
				} else {
					obj.removeClass('focus').addClass('ated').html('已关注').attr('data','/user-userdo-delfocus-uid-'+obj.attr('val'));
				}
				if (typeof(getfocusuid) == 'function') {
					getfocusuid();
				}
			}
		},
		dataType: 'json'
	});
});
//点击跳到锚点处
$("[href*='#']").click(function() {
	if (location.pathname.replace(/^\//, "") == this.pathname.replace(/^\//, "") && location.hostname == this.hostname) {
		var a = $(this.hash);
		a = a.length && a || $("[name=" + this.hash.slice(1) + "]");
		if (a.length) {
			var b = a.offset().top - 10;
			$("html,body").animate({
				scrollTop: b
			}, 300);
			return false
		}
	}
});
//动漫弹层
IKF.showPop(500)
//设置站外站内
// IKF.setOut();
//判断有没有设置过站内播放
// IKF.usedSetPlay();
// IKF.onSetPlay($('.setting'));
//组合键功能调用
// IKF.shortcuts();
IKF.hs($(".qr-code-ico"),$(".qr-code"),'qr-code-ico-hover');
IKF.hs($(".shang"),$("#shang"),'');
IKF.hs($(".weixin"),$("#weixin"),'');
//判断是否显示其他资源
// IKF.isOther()
//收藏和订阅
IKF.clickRss();
//排行榜
IKF.rankTop($('.d-hotlist li'));
//图超出指定高度，鼠标放上去自动滚动超出部分
IKF.imgHeight();
//图片延时加载
$(".loading").scrollLoading();
//左右不等高的时候滚动
IKF.HomeScroll(".d-warp-left",".d-warp-right",25,-25);
IKF.HomeScroll(".d-news-left",".index-right",10,-10);
IKF.HomeScroll(".d-left",".d-right",10,-10);
IKF.HomeScroll(".filter-nav",".filter-box",20,-20);
});
